using namespace inilib;


template <typename T>
OptionTypeNumeric< T >::OptionTypeNumeric (
	const std::string & optionName,
	Mandatory isMandatory,
	ValuesAmount amount,
	const T & defaultValue,
	const T & minValue,
	const T & maxValue,
	char separator
)
	: OptionType( optionName, isMandatory, amount, separator )
{
	m_MinValue = minValue;
	m_MaxValue = maxValue;

	std::stringstream ss;
	ss << defaultValue;
	m_DefaultValue.push_back( ss.str() );
}


template <typename T>
std::vector< std::string > OptionTypeNumeric< T >::GetDefaultValue () const
{
	return m_DefaultValue;
}


template <typename T>
bool OptionTypeNumeric< T >::AreValuesValid_ ( const std::vector< std::string > & values ) const
{
	std::stringstream ss;
	for ( size_t i = 0; i < values.size(); ++i )
	{
		ss.clear();
		ss.str( values[ i ] );

		T out;
		inilib::operator>>( ss, out );

		if ( ss.fail() )
		{
			return false;
		}
		
		std::string rem;
		ss >> rem;
		if ( rem != "" )
		{
			// there is something behind this number:
			return false;
		}

		if ( out < m_MinValue || out > m_MaxValue )
		{
			return false;
		}
	}

	return true;
}
